package com.aier.common.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.eicp.ghostboy.futil.StringUtil;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.aier.common.common.CityBean;
import com.aier.common.common.CityUtil;

@Scope("prototype")
@Component("commonCityAction")
public class CommonCityAction extends CommonBaseAction {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private List<CityBean> cb;

    private boolean loaddata;
    private String vname;
    private String id;
    private Map<Integer,String> cmap;
    private int s;
    private int cityId;

    /**
     * 城市列表单项选择器
     * @return
     */
    public String dx() {
        if (loaddata) {
            cb = new ArrayList<CityBean>();
            Map<Integer, String> province = CityUtil.getProvince();
            for (Integer cid : province.keySet()) {
                cb.addAll(CityUtil.getSubCity(cid));
            }
        }
        if(StringUtil.isStringNull(id)){
            id="citySelect";
        }
        return "dx";
    }

    /**
     * 城市列表多想选择器
     * @return
     */
    public String cj(){
        cb = new ArrayList<CityBean>();
        Map<Integer, CityBean> province = CityUtil.getProvinceAll();
        for (Integer cid : province.keySet()) {
            cb.addAll(CityUtil.getSubCity(cid));
            cb.add(province.get(cid));
        }
        return "cj";
    }
    
    /**
     * 
     * @return
     */
    public String cc(){
        
        return "cc";
    }

    public String cc1(){
        
        return "cc1";
    }
    
    public String loadCity(){
        if(cityId==-1){
            cmap=CityUtil.getProvince();
        }else{
            cmap=CityUtil.getSubCityMap(cityId);
        }
        s=1;
        return SUCCESS;
    }
    
    
    
    public List<CityBean> getCb() {
        return cb;
    }

    public void setLoaddata(boolean loaddata) {
        this.loaddata = loaddata;
    }

    public String getVname() {
        return vname;
    }

    public void setVname(String vname) {
        this.vname = vname;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isLoaddata() {
        return loaddata;
    }



    public Map<Integer, String> getCmap() {
        return cmap;
    }

    public int getS() {
        return s;
    }

    public int getCityId() {
        return cityId;
    }

    public void setCityId(int cityId) {
        this.cityId = cityId;
    }

    
}
